<div class="row">
  <div class="col-xs-12">
    <%= render partial: 'common/nav', locals: {show_tab: :index, model_nav_name: :admin_code_table, pjax: true} %>
    <div id="admin_code_tables">
      <%= form_for 'CodeTable', url: admin_code_tables_destroy_multi_path, method: :post do %>
          <button class="btn btn-minier btn-danger" type="submit"><i class="icon-trash"></i> <%= t 'common.delete_multi' %></button>
          <%= grid(@code_tables, show_filters: :when_filtered) do |g|
            g.action_column param_name: :select_ids, object_property: :id
            g.column name: "#{t 'activerecord.attributes.defaults.id'}", attribute: 'id', filter: false, ordering: true
            g.column name: "#{t 'activerecord.attributes.code_table.name'}", attribute: 'name' do |c|
              link_to c.name, admin_code_table_path(c.id), class: :pjax
            end
            g.column name: "#{t 'activerecord.attributes.code_table.default_value'}", attribute: 'default_value'

            g.column name: "#{t 'activerecord.attributes.code_table.parent'}", attribute: 'parent_id',
                     custom_filter: CodeTable.all.map { |c| [c.name, c.id] } do |c|
                       c.parent.name if c.parent_id.present?
                     end
            g.column name: "#{t 'activerecord.attributes.code_table.position'}", attribute: 'position'
            g.column name: "#{t 'activerecord.attributes.code_table.remark'}", attribute: 'remark'

            g.column do |c|
              grid_operator(:admin_code_table_path, c.id)
            end
          end %>
      <% end %>
    </div>

    <script>
        $(function () {
            $('.nav.nav-list li.active').removeClass('active');
            $('.nav.nav-list li[data-model="code_table_list"]').addClass('active');
        });
    </script>
  </div>
</div>